package kr.hkit.powerjava.chapter10;

import java.util.Arrays;
import java.util.Random;

public class LottoGenerater {

	private int[] arr;
	private static final int SIZE = 6;
	private Random rnd;
	
	public LottoGenerater() {
		arr = new int[LottoGenerater.SIZE];
		rnd = new Random();
	}
	
	public void getLottoNum(){
		int num = -1;
		for (int i = 0; i < arr.length; i++) {
			
			/*
			num = getNum();
			while(isFind(num)){}
			arr[i] = num;
			*/
			
			System.out.println(isFind(num));
			if(!isFind(num)){
				arr[i] = num;
			}
			else{
				i--;
			}
			
			
			/*
			 * while(true){
				num = getNum();
				
				if(!isFind(num)){
					arr[i] = num;
					break;
				}
			}
			*/
		}
	}
	
	public int getNum(){
		return rnd.nextInt(45) + 1;
	}
	
	public boolean isFind(int searchNum){
		for (int i = 0; i < arr.length; i++) {
			if(searchNum == arr[i]){
				return true;
			}
		}
		return false;
	}
	
	@Override
	public String toString() {
		return "LottoGenerater " + Arrays.toString(arr);
	}

	public static void main(String[] args) {
		LottoGenerater lo = new LottoGenerater();
		System.out.println(lo);
		lo.getLottoNum();
		System.out.println(lo);
		
	}
}
